package com.guit.hrms.utils;

import com.guit.hrms.dto.wx.WxMessageDTO;
import org.springframework.stereotype.Component;

import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

@Component
public class WeChatMsgUtil {
    public static Map<String, Object> buildMsg(WxMessageDTO wxMessageDTO) {
        Map<String, Object> data = new HashMap<>();
        data.put("thing1", new HashMap<String, Object>() {{
            put("value", wxMessageDTO.getThings());
        }});
        data.put("short_thing15", new HashMap<String, Object>() {{
            put("value", wxMessageDTO.getType());
        }});
        data.put("phrase2", new HashMap<String, Object>() {{
            put("value", wxMessageDTO.getResult());
        }});
        data.put("time10", new HashMap<String, Object>() {{
            put("value", wxMessageDTO.getTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        }});
        data.put("thing13", new HashMap<String, Object>() {{
            put("value", wxMessageDTO.getApprover());
        }});
        return data;
    }
}
